/**
 * ...
 * @author Hatshepsout
 */

function FicheSaver(){}

FicheSaver.onComplete = null;

FicheSaver.save = function(url,data,preview)
{
	var http = new XMLHttpRequest();
	var url = url;
	var params = "data="+data+"&preview="+preview;
	var scope = this;
	http.open("POST", url, true);

	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");

	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			if( scope.onComplete != null )
			{
				scope.onComplete(http.responseText);
			}
		}
	}
	http.send(params);
};